package com.example.activity;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.AbsListView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.example.administrator.olddoctor.R;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

/**
 *追姐详情页
 */
public class TrackDetailActivity extends AppCompatActivity implements View.OnClickListener,AbsListView.OnScrollListener{

    ListView listView;

    private EditText editText_trackdetail;
    private ImageView imageView5_trackdetail;//评论
    private ImageView imageView4_trackdetail;//分享
    private Button button_trackdetail;//追姐

    private FloatingActionButton join;

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.activity_trackdetail);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_track);
        toolbar.setTitle("追姐详情页");
        setSupportActionBar(toolbar);

        JCVideoPlayerStandard player = (JCVideoPlayerStandard) findViewById(R.id.jc_video_track);
        listView = (ListView) findViewById(R.id.listview_123_track);
        editText_trackdetail = (EditText) findViewById(R.id.editText_trackdetail);
        imageView5_trackdetail = (ImageView) findViewById(R.id.imageView5_trackdetail);
        imageView4_trackdetail = (ImageView) findViewById(R.id.imageView4_trackdetail);
        button_trackdetail= (Button) findViewById(R.id.button_trackdetail);
        join = (FloatingActionButton) findViewById(R.id.join_trackdetail);

        player.setUp("http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4"
                , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "我是一个标题");
        Picasso.with(this)
                .load("http://cos.myqcloud.com/1000264/qcloud_video_attachment/842646334/vod_cover/cover1458036374.jpg")
                .into(player.thumbImageView);

        Map<String, String> keyValuePair = new HashMap<>();
        keyValuePair.put("key", "list item");
        List<Map<String, String>> list = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            list.add(keyValuePair);
        }

        ListAdapter adapter = new SimpleAdapter(this, list,
                android.R.layout.simple_list_item_1, new String[]{"key"}, new int[]{android.R.id.text1});

        listView.setAdapter(adapter);
        listView.setOnScrollListener(this);


    }


    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        JCVideoPlayer.onScroll();
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()){
            case R.id.join_trackdetail:

                break;
        }
    }
}
